<!-- 商品分类列表 -->
<template>
  <s-layout title="购买净水器" :bgStyle="{ color: '#fff' }">
    <category />
  </s-layout>
</template>

<script setup>
  import sheep from '@/sheep';

  import category from '@/pages/index/components/categoryutil.vue';
  import { onMounted, computed } from 'vue';
  import UserApi from '@/sheep/api/member/user';

  onMounted(async () => {
    const isLogin = computed(() => sheep.$store('user').isLogin); //没登录则会被驳回
    console.log("isLogin", isLogin.value);
    if (!isLogin.value) {
      sheep.$router.go('/pages/index/mainlogin');
    }
    const isName = await UserApi.isNameAuthenication(); //没实名认证则会被驳回
    console.log("isName", isLogin.value);
    if (!isName.data) {
      sheep.$router.go('/pages/register/auth-identification');
    }
    const levelId = await UserApi.levelId(); //判断是否0级
    if (levelId.data == true) {
      const isGrant = await UserApi.isGrant(); //查看用户是否已经通过认证
      if (isGrant.data) {
        setTimeout(() => {
          sheep.$helper.toast('欢迎使用本公司净水器');
          sheep.$router.go('/pages/index/index');
        }, 1000);
      } else {
        setTimeout(() => {
          sheep.$helper.toast('您已购买本公司产品，请查询订单进度');
          sheep.$router.go('/pages/order/list');
        }, 1000);
      }
    }
  });
</script>

<style lang="scss" scoped>
  @import '@/sheep/components/s-auth-modal/index.scss';

  .head-box,
  button {
    margin: 30px;
    width: auto;
    height: auto;
  }
</style>
